<!--发言量饼图页面-->
<template>
  <div
    ref="chart"
    style="margin: 0 auto; width: 600px; height:70ch;"
  />
</template>

<script>
import axios from 'axios'
export default {
  name: 'Proportion',
  data() {
    return {
      option: {}
    }
  },
  mounted() {
    this.initCharts()
    // this.getData()
    this.getDataLocal()
  },
  methods: {
    initCharts() {
      this.chart = this.$echarts.init(this.$refs.chart)
    },
    getData() {
      axios.get('api/proportion').then((res) => {
        this.option = res.data
      }).catch((err) => {
        console.log(err)
      })
    },
    getDataLocal() {
      this.option = {
        tooltip: {
          trigger: 'item'
        },
        legend: {
          top: '5%',
          left: 'center'
        },
        series: [
          {
            name: 'Access From',
            type: 'pie',
            radius: ['40%', '70%'],
            avoidLabelOverlap: false,
            itemStyle: {
              borderRadius: 10,
              borderColor: '#fff',
              borderWidth: 2
            },
            label: {
              show: false,
              position: 'center'
            },
            emphasis: {
              label: {
                show: true,
                fontSize: '40',
                fontWeight: 'bold'
              }
            },
            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: '杨洁篪' },
              { value: 735, name: '王毅' },
              { value: 580, name: 'Antony Blinken' },
              { value: 484, name: 'Jake Sullivan' }
            ]
          }
        ]
      }
    }
  },
  watch: {
    option: {
      handler(option) {
        this.chart.setOption(this.option)
      },
      deep: true
    }
  }
}
</script>

